/**
 * @file Describe the file
 */
var BaseUtil = new BaseUtil();
var CommonUtil = new CommonUtil();
$(function () {
    $('.side-menu').slide({
        titCell: 'h3',
        targetCell: 'ul',
        defaultIndex: 0,
        effect: 'slideDown',
        delayTime: '500',
        trigger: 'click',
        triggerTime: '150',
        defaultPlay: true,
        returnDefault: false,
        easing: 'easeInQuint',
        endFun: function () {
            scrollWW();
        }
    });
    $(window).resize(function () {
        scrollWW();
    });

    $('li').click(function () {
        $('li').removeClass('on');
        $(this).addClass('on');
    });

    $.ajax({
        cache: true,
        type: 'get',
        url: CommonUtil.getRootPath() + '/currentUser',
        async: true,
        success: function (data) {
            $('#currentUserName').html(data);
        },
        error: function (data) {
            BaseUtil.resultError(data);
        }
    });

});

function scrollWW() {
    if ($('.side').height() < $('.side-menu').height()) {
        $('.scroll').show();
        var pos = $('.side-menu ul:visible').position().top - 38;
        $('.side-menu').animate({
            top: -pos
        });
    } else {
        $('.scroll').hide();
        $('.side-menu').animate({
            top: 0
        });
        n = 1;
    }
}

var n = 1;
function menuScroll(num) {
    var Scroll = $('.side-menu');
    var ScrollP = $('.side-menu').position();
    if (Number(num) === 1) {
        Scroll.animate({
            top: ScrollP.top - 38
        });
        n = n + 1;
    } else {
        if (Number(ScrollP.top) > -38 && Number(ScrollP.top) !== 0) {
            ScrollP.top = -38;
        }
        if (ScrollP.top < 0) {
            Scroll.animate({
                top: 38 + ScrollP.top
            });
        } else {
            n = 1;
        }
        if (n > 1) {
            n = n - 1;
        }
    }
}

function selectMenu(t, u, c) {
    CommonUtil.removeAllData(); // 清空缓存中的后退操作保存的页码数据
    if (null == u || '' === String(u)) {
        $('#rightMain').attr('src', 'page/main.html');
    } else {
        $('#here_area').html(c);
        $('#rightMain').attr('src', u);
    }
}